import Vue from 'vue'
import VueRouter from 'vue-router'
import GetupView from '../views/GetupView.vue'
import ActivityView from '../views/ActivityView.vue'
import MyView from '../views/MyView.vue'
import HotlistView from '@/components/getup/getup-hot-list/HotlistView.vue'
import GetupModernDrama from '@/components/getup/getup-modern-drama/GetupModernDrama.vue'
import VideoView from '@/components/getup/getup-video/VideoView.vue'
import DynamicView from '@/components/getup/getup-dynamic/DynamicView.vue'
import BannerDetail from '@/components/banner-detail/BannerDetail'
import GoPayDetail from '@/components/go-pay-detail/GoPayDetail'
import PlusCardPage from '@/components/plus-card/PlusCardPage.vue'
import BusinessesPage from '@/components/businesses/BusinessesPage.vue'
import PostsPage from '@/components/posts/PostsPage.vue'
import MoreList from '@/components/activity/more-list/MoreList.vue'
import ChaperonePage from '@/components/chaperone/ChaperonePage.vue'
import ChaperoneSquare from '@/components/chaperone/ChaperoneSquare.vue'
import ShareImg from '@/components/share-view/ShareImg.vue'
import PictureWall from '@/components/businesses/picture-wall/PictureWall.vue'
import AuthorInfo from '@/components/businesses/userinfo/AuthorInfo.vue'
import SearchPage from '@/components/search/SearchPage.vue'
import CityList from '@/components/search/CityList.vue'
import SearchMoreList from '@/components/search/SearchMoreList.vue'
import SubjectPage from '@/components/search/SubjectPage'
import RecommendView from '@/components/businesses/businesses-recommend/RecommendView.vue'
import CommentView from '@/components/getup/getup-comment/CommentView.vue'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
}

const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch((err) => err)
}

Vue.use(VueRouter)

const routes = [
  //走起页面
  {
    path: '/getup',
    name: 'getup',
    component: GetupView
  },
  //走起页面

  {
    path: '',
    redirect: '/getup'
  },
  //走起页面
  {
    path: '/',
    redirect: '/getup'
  },
  //活动页面
  {
    path: '/activity',
    name: 'activity',
    component: ActivityView
  },
  //我的页面
  {
    path: '/user',
    name: 'user',
    component: MyView
  },
  //跳转展览热度榜
  {
    path: '/host',
    name: 'host',
    component: HotlistView
  },

  //跳转话剧演出热度榜
  {
    path: '/drama',
    name: 'drama',
    component: GetupModernDrama
  },

  //跳转视频
  {
    path: '/video/:id',
    name: 'video',
    component: VideoView,
    props: true // 开启路由传参，跳转过去的页面，可以自定义属性来接受这个id
  },

  //跳转动态
  {
    path: '/dynamic/:id',
    name: 'dynamic',
    component: DynamicView,
    props: true
  },
  // 轮播图详情页路由规则
  {
    path: '/bannerdetail/:id',
    name: 'bannerdetail',
    component: BannerDetail,
    props: true
  },
  // 点击支付按钮详情页面
  {
    path: '/feeds/:id',
    name: 'feed',
    component: GoPayDetail,
    props: true
  },
  // 会员路由规则
  {
    path: '/cardpage',
    name: 'cardpage',
    component: PlusCardPage
  },
  // 点击活动路由跳转路由规则
  {
    path: '/businesses/:id',
    name: 'businesses',
    component: BusinessesPage,
    props: true
  },
  // 晒图详情路由规则
  {
    path: '/posts/:id',
    name: 'posts',
    component: PostsPage,
    props: true
  },
  // 活动页面点击跳转更多活动页面右路规则
  {
    path: '/morelist/:id',
    name: 'morelist',
    component: MoreList,
    props: true
  },
  // 约伴页面路由规则
  {
    path: '/chaperone/:id',
    name: 'chaperone',
    component: ChaperonePage,
    props: true
  },
  // 约伴广场路由规则
  {
    path: '/chaperonesquare',
    name: 'chaperonesquare',
    component: ChaperoneSquare
  },
  // 分享路由规则
  {
    path: '/share/:id',
    name: 'share',
    component: ShareImg,
    props: true
  },
  // 照片墙路由规则
  {
    path: '/picturewall/:id',
    name: 'picturewall',
    component: PictureWall,
    props: true
  },

  //跳转到评论
  {
    path: '/comment/:id',
    name: 'comment',
    component: CommentView,
    props: true
  },

  // 活动详情页面路由规则

  {
    path: '/authorcenter/:id',
    name: 'authorcenter',
    component: AuthorInfo,
    props: true
  },
  // 搜索页面路由规则
  {
    path: '/search',
    name: 'search',
    component: SearchPage
  },
  // 城市筛选列表
  {
    path: '/citylist',
    name: 'citylist',
    component: CityList
  },
  // 搜索页面更多活动路由规则
  {
    path: '/searchmorelist',
    name: 'searchmorelist',
    component: SearchMoreList
  },
  // 搜索页面点击tag调转路由规则
  {
    path: '/subject/:id',
    name: 'subject',
    component: SubjectPage,
    props: true
  },
  {
    path: '/recommend/:title',
    name: 'recommend',
    component: RecommendView,
    props: true

  }
]

const router = new VueRouter({
  routes
})

export default router
